﻿/*
This file is under Microsoft Public License (MS-PL)
Copyright Yohann MARTEL.  All rights reserved.
Codeplex: http://amf.codeplex.com
AMF Website: http://www.ymartel.com/aspnet-mobile-framework/
*/
using System;
using System.Web.UI;

namespace Mobile.WebControls.Field
{
    internal class Label : ThemedControl
    {
        #region Properties
        public string Text { get; set; }
        public string ForId { get; set; }
        public bool UsedForComboBox { get; set; }
        #endregion

        #region Render Methods

        public override void RenderBeginTag(HtmlTextWriter writer)
        {
            AddAttributesToRender(writer);
            writer.RenderBeginTag(HtmlTextWriterTag.Label);
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            base.RenderContents(writer);
            writer.Write(Text);
        }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            base.AddAttributesToRender(writer);
            if (!String.IsNullOrEmpty(ForId))
            {
                writer.AddAttribute(MetadataAttribute.For, ForId); 
            }
            if (UsedForComboBox)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, JqueryCssClass.Select);
            }
        }

        public override void RenderEndTag(HtmlTextWriter writer)
        {
            writer.RenderEndTag();
        }
        #endregion
    }
}
